package com.chuanyang.driverh.mainorder.adapter;


import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RatingBar;
import android.widget.TextView;

import com.chuanyang.driverh.R;
import com.chuanyang.driverh.base.BaseListAdapter;
import com.chuanyang.driverh.responseresult.ShipperMsgData;

import java.util.List;

public class GoodsOwnerCommentsdapter extends BaseListAdapter<ShipperMsgData.DriverEvaluateMsgsBean> {
    public void setObjects(List<ShipperMsgData.DriverEvaluateMsgsBean> objects) {
        this.objects = objects;
        notifyDataSetChanged();
    }

    private List<ShipperMsgData.DriverEvaluateMsgsBean> objects;
    private Context context;
    private ViewHolder viewHolder;


    public GoodsOwnerCommentsdapter(Context context, List<ShipperMsgData.DriverEvaluateMsgsBean> objects) {
        super(context, objects);
        this.context=context;
        this.objects=objects;
    }

    @Override
    public View getZkView(int position, View convertView, ViewGroup parent) {
        if (convertView==null)
        {
              convertView= View.inflate(context, R.layout.order_item_goodownerscomments,null);
            viewHolder = new ViewHolder();
            viewHolder.tv_goodownercomment_star= (RatingBar) convertView.findViewById(R.id.tv_goodownercomment_star);
            viewHolder.tv_goodownercomment_begadd= (TextView) convertView.findViewById(R.id.tv_goodownercomment_begadd);
            viewHolder.tv_goodownercomment_endadd= (TextView) convertView.findViewById(R.id.tv_goodownercomment_endadd);
            viewHolder.tv_goodownercomment_satisfaction= (TextView) convertView.findViewById(R.id.tv_goodownercomment_satisfaction);
            viewHolder.tv_goodownercomment_content= (TextView) convertView.findViewById(R.id.tv_goodownercomment_content);
            convertView.setTag(viewHolder);
        }
        else {
            viewHolder= (ViewHolder) convertView.getTag();
        }
        ShipperMsgData.DriverEvaluateMsgsBean bean=objects.get(position);
        viewHolder.tv_goodownercomment_begadd.setText(bean.getStartAddr());
        viewHolder.tv_goodownercomment_endadd.setText(bean.getTargetAddr());
        viewHolder.tv_goodownercomment_star.setRating(bean.getStar());
        viewHolder.tv_goodownercomment_content.setText(bean.getEDetail());
        if(bean.getStar()>=4)
        {
            viewHolder.tv_goodownercomment_satisfaction.setText("满意");
        }
        else {
            viewHolder.tv_goodownercomment_satisfaction.setText("");
        }

//         //设置数据后期写
        return convertView;
    }

    class ViewHolder
    {
        RatingBar tv_goodownercomment_star;
        TextView tv_goodownercomment_begadd;
        TextView tv_goodownercomment_endadd;
        TextView tv_goodownercomment_satisfaction;
        TextView tv_goodownercomment_content;

    }
}
